Crate amplify_derive
source ·Expand description
Amplifying Rust language capabilities: multiple generic trait implementations, type wrappers, derive macros.
Derive Macros§
- Trait
amplify::AsAny
allows simple conversion of any type into a generic “thick” pointer&dyn Any
(see::core::any::Any
), that can be later converted back to the original type with a graceful failing for all other conversions.AsAny
derive macro allows to implement this trait for arbitrary time without much hussle: - Usage
- Error derive macro works to the full extend only when other derive macros are used. With
#[derive(Display)]
and[display(doc_comments)]
it uses doc comments for generating error descriptions; with#[derive(From)]
it may automatically implement transofrations from other error types. - Derives getter methods for structures. The return type and naming of the methods depends on the provided attribute arguments.
- Creates rust new type wrapping existing type. Can be used in structures containing multiple named or unnamed fields; in this case the field you’d like to wrap should be marked with
#[wrap]
attribute; otherwise the first field is assumed to be the wrapped one. - Derives
WrapperMut
and allows deriving other traits accessing the wrapped type which require mutable access to the inner type. Requires that the type already implementsamplify::Wrapper
.